package cn.js.feign;

import cn.js.dto.User;
import cn.js.feign.fallback.UserFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(value = "user-server",fallbackFactory = UserFeignClientFallback.class, contextId = "user1")
public interface UserFeignClient {

    @PostMapping("/user/get_user_list")
    String getUserList(@RequestBody User user);
    @GetMapping("/user/get_data")
    String getData();

    @GetMapping("/user/get_arr")
    String getArr(@RequestParam("arr") String[] arr);

    //注意：openfeign 中对象传参只能使用 POST，并且也符合使用习惯
    //GET 请求传对象会报错: Method Not Allowed
    @PostMapping("/user/get_user")
    String getUser(@RequestBody User user);

    @GetMapping("/user/{name}")
    String getName(@PathVariable("name") String name);
    @GetMapping("/user/get_info")
    String getInfo(@RequestParam("id") Long id);

    @GetMapping("/user/user/{id}")
    User getById(@PathVariable Long id);



}